Problem: In triangle $ABC,$ $b = 5,$ $c = 4,$ and $\cos (B - C) = \frac{31}{32}.$  Find $a.$

Note: $a$ is the side length opposite $\angle A,$ etc.
Answer: By the Law of Cosines,
\[a^2 = 5^2 + 4^2 - 2 \cdot 5 \cdot 4 \cos A = 41 - 40 \cos A.\]In general, $\cos (B - C) - \cos (B + C) = 2 \sin B \sin C.$  We know $\cos (B - C) = \frac{31}{32}$ and
\[\cos (B + C) = \cos (180^\circ - A) = -\cos A.\]By the Law of Sines,
\[\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C},\]so $\sin B = \frac{5 \sin A}{a}$ and $\sin C = \frac{4 \sin A}{a}.$  Hence,
\[\frac{31}{32} + \cos A = \frac{40 \sin^2 A}{a^2}.\]Then
\[\frac{31}{32} + \cos A = \frac{40 (1 - \cos^2 A)}{41 - 40 \cos A}.\]This simplifies to $\cos A = \frac{1}{8}.$  Then
\[a^2 = 41 - 40 \cos A = 36,\]so $a = \boxed{6}.$